import 'package:flutter/material.dart';

class TimeLine extends StatefulWidget {
  const TimeLine({super.key});

  @override
  State createState() => TimeLineState();
}

class TimeLineState extends State<TimeLine> {

  final List textList = [
      "ChatGPT 爆发意味着 AI 的 iPhone 时刻来了，下一步就是应用时刻，新应用时代将来临。那程序员怎么办呢？会被替代吗？",
      "程序员不会被替代，但程序员的技术栈将发生变化。",
      "ChatGPT 会让人工智能技术进入应用阶段，开启新应用时代。",
      "第一批 AI 应用不会是 C 端方面的，而是在 To B 迎来一场大爆发。",
      "未来肯定会出现开源开放的 AI OS，会出现中国自己的 AI OS。",
      "CSDN 历史很悠久，程序员天生离不开开放、共享、协作，所以开源的概念最初诞生于程序员的社区。CSDN 在过去的一年有很大的增长，现已拥有 4200 万的用户总量，并在去年新增了 600 万用户。",
  ];

  @override
  Widget build(BuildContext context) {
     return Container(
         color: Colors.white,
         child: Column(
           children: [
             Padding(
               padding: const EdgeInsets.all(15),
               child: Stack(
                 children: [
                     //线
                     // Positioned(
                     //      height: double.infinity,
                     //     left: 10,
                     //     top: 10,
                     //      child: Container(width: 1,color: Colors.yellow),
                     // ),
                     Column(
                         crossAxisAlignment: CrossAxisAlignment.start,
                         children: List.generate(textList.length, (index) {
                             if (textList.length - 1 != index) {
                               return Stack(
                                   children: [
                                    Container(
                                      padding: const EdgeInsets.only(bottom: 10),
                                      child: Column(
                                        children: [
                                          Row(
                                            crossAxisAlignment: CrossAxisAlignment.start,
                                            children: [
                                              Container(
                                                width: 20,
                                                height: 20,
                                                alignment: Alignment.center,
                                                child: Container(
                                                   width: 8,
                                                   height: 8,
                                                   decoration: BoxDecoration(
                                                     borderRadius: BorderRadius.circular(6),
                                                     color: Colors.yellow
                                                   ),
                                                ),
                                              ),
                                              const SizedBox(width: 5,),
                                              Expanded(child: Text(
                                                textList[index],
                                                style: const TextStyle(
                                                  color: Colors.grey,
                                                  fontSize: 14,
                                                ),
                                               )
                                              )
                                            ],
                                          ),
                                          const SizedBox(width: 5,),
                                          Row(
                                            children: const [
                                              SizedBox(width: 25,),
                                              Text(
                                                "2022-10-15 10:10:10",
                                                style: TextStyle(
                                                    color: Colors.grey,
                                                    fontSize: 14),
                                              ),
                                            ],
                                          )
                                        ],
                                     ),
                                   ),

                                   Positioned(
                                       top: 10,
                                       left: 10,
                                       bottom: 0,
                                       child: Container(width: 1, color: Colors.yellow,)),
                                ]);
                             } else {
                              return Container(
                                 padding: const EdgeInsets.only(bottom: 10),
                                 child: Column(
                                     children: [
                                       Row(
                                         crossAxisAlignment: CrossAxisAlignment.start,
                                         children: [
                                           Container(
                                             width: 20,
                                             height: 20,
                                             alignment: Alignment.center,
                                             child: Container(
                                               width: 8,
                                               height: 8,
                                               decoration: BoxDecoration(
                                                   borderRadius: BorderRadius.circular(6),
                                                   color: Colors.yellow
                                               ),
                                             ),
                                           ),
                                           const SizedBox(width: 5,),
                                           Expanded(child: Text(
                                             textList[index],
                                             style: const TextStyle(
                                               color: Colors.grey,
                                               fontSize: 14,
                                             ),
                                           )
                                           )
                                         ],
                                       ),
                                       const SizedBox(width: 5,),
                                       Row(
                                         children: const [
                                           SizedBox(width: 25,),
                                           Text(
                                             "2022-10-15 10:10:10",
                                             style: TextStyle(
                                                 color: Colors.grey,
                                                 fontSize: 14),
                                           ),
                                         ],
                                       ),
                                     ],
                                 ),
                              );
                             }
                           }
                         ),
                      ),
                   ],
               ),
             )
           ],
         ),
     );
  }
}